<?php
  class Media_m extends Model{
      function Media_m(){
          parent::Model();
          $this->load->database();
      }
      function get_all_videos($per_page,$off_set){
          $this->db->select();
          $this->db->from('seating_videos');
          $this->db->order_by('seating_videos.id DESC');
          $this->db->limit($per_page,$off_set);
          return $this->db->get()->result_array();
      }

      function get_comment_videos($video_id,$per_page,$off_set){
          $this->db->select('seating_video_comment.id,seating_video_comment.user_id,seating_video_comment.video_id,seating_video_comment.comment,
              seating_video_comment.comment_date,seating_videos.name,lehu_profiles.gravatar,lehu_profiles.display_name');
          $this->db->from('seating_video_comment,seating_videos,lehu_profiles');
          $this->db->where('seating_video_comment.video_id = seating_videos.id');
          $this->db->where('seating_video_comment.user_id = lehu_profiles.user_id');
          $this->db->where('seating_video_comment.video_id',$video_id);
          $this->db->order_by('seating_video_comment.id DESC');
          $this->db->limit($per_page,$off_set);
          return $this->db->get()->result_array();
      }

      function count_comment_videos($video_id){
          $this->db->select();
          $this->db->from('seating_video_comment');
          $this->db->where('seating_video_comment.video_id',$video_id);
          $this->db->order_by('seating_video_comment.id DESC');
          return count($this->db->get()->result_array());
      }

      function get_video_details($id){
            $this->db->select('lehu_profiles.display_name,seating_videos.id,seating_videos.name,
            seating_videos.description,seating_videos.file_name,
            seating_videos.upload_time,seating_videos.upload_by');
            $this->db->from('seating_videos,lehu_users,lehu_profiles');
            $this->db->where('seating_videos.upload_by = lehu_users.id ');
            $this->db->where('lehu_users.id = lehu_profiles.user_id');
            $this->db->where('seating_videos.id',$id);
            $query = $this->db->get();
            return $query;
      }

      function comment_video($data){
          return $query = $this->db->insert('seating_video_comment', $data);
      }
  }
?>
